<template>
  <div class="student-manage">
    <div class="head">全部待审核内容</div>
    <div class="select-button">
      <el-row>
        <el-col :span="12">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-input v-model="inputNickname" placeholder="请输入用户姓名关键词" ></el-input>
            </el-col>
            <el-col :span="12">
              <el-select v-model="inputStatus" placeholder="选择内容状态">
                <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="4" :offset="1">
          <el-select v-model="inputContentType" placeholder="选择内容类型">
            <el-option
                v-for="item in contentOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="3">
          <el-button  type="primary" icon="el-icon-search" @click="pageCheckList()">查询</el-button>
        </el-col>
        <el-col :span="3">
          <el-button  type="primary" icon="el-icon-search" @click="clear()">清空</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="check-list" style="display: flex;flex-direction: column;align-items: center">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="selection" width="55"  align="center">
        </el-table-column>
        <el-table-column fixed prop="id" label="用户ID" min-width="50%" align="center">
        </el-table-column>
        <el-table-column prop="nickname" label="发起人" min-width="40%" align="center" >
        </el-table-column>
        <el-table-column prop="status" label="审核状态" min-width="40%" align="center" >
        </el-table-column>
        <el-table-column prop="contentType" label="内容类型" min-width="40%" align="center" >
        </el-table-column>
        <el-table-column prop="gmtCreate" label="发起时间" min-width="50%" align="center" >
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="250">
          <template slot-scope="scope">
            <el-button @click="beginInfoEdit(scope.row)" type="text" size="medium">去审核</el-button>
          </template>
        </el-table-column>
      </el-table>

      <div class="block" style="margin-top: 20px">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[8, 10, 20, 40]"
            :page-size="8"
            layout="total, sizes, prev, pager, next, jumper"
            :total="parseInt(total)">
        </el-pagination>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  name: "CheckManageView",
  data() {
    return {
      total: 0,
      currentSize: 8,
      currentPage: 1,

      inputNickname: "",
      inputStatus: "",
      inputContentType: '',

      tableData: [],

      options: [{
        value: 0,
        label: '待审核'
      }, {
        value: 1,
        label: '审核通过'
      },{
        value: 2,
        label: '审核不通过'
      }],

      contentOptions: [{
        value: 0,
        label: '求索-问题'
      }, {
        value: 1,
        label: '求索-观点'
      }, {
        value: 2,
        label: '求索-回答'
      }]
    };
  },
  mounted() {
    this.pageCheckList();
  },
  methods: {
    pageCheckList() {
      console.log("name:"+this.inputNickname,"type"+this.inputContentType,"status"+this.inputStatus)
      this.$api.pageCheckList({
        pageSize: this.currentSize,
        pageNow: this.currentPage,
        nickname: this.inputNickname || '',
        contentType: this.inputContentType,
        sourceId : this.$route.params.id,
        status : this.inputStatus
      })
          .then((res) => {
            let list = res.data.rows;
            this.total = res.data.totalPage
            console.log(this.total)
            this.tableData = list
          });
    },
    handleSizeChange(val) {
      this.currentSize = parseInt(val);
      this.pageUsers();
    },
    handleCurrentChange(val) {
      this.currentPage = parseInt(val);
      this.pageUsers();
    },

    clear(){
      this.inputNickname = ''
      this.inputStatus = ''
      this.inputContentType = ''
      this.pageCheckList();
    }

  },
};
</script>

<style scoped>
.student-manage{
  margin-top: 20px;
  width: 100%;
}


.head {
  padding-bottom: 10px;
}

.select-button {
  padding: 10px 0;
}

.check-list {
  width: 100%;
  padding: 10px 0;
  display: flex;
}
</style>
